<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 基本表单</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="../favicon.ico">
    <link href="/Public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/Public/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/Public/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/css/animate.css" rel="stylesheet">
    <link href="/Public/css/style.css?v=4.1.0" rel="stylesheet">

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>公告中心-
                        <small>发布公告</small>
                    </h5>

                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" onsubmit="return false">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">*标题</label>
                            <div class="col-sm-10">
                                <input  class="form-control" type="text" name="title" id="title" placeholder="请输入标题"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*公告详情</label>
                            <div class="col-sm-10">
                                <textarea id="content" name="content"  cols="70" rows="11" placeholder="请输入公告详情"></textarea>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="back_add()">添加</button>
                                <button class="btn btn-white" type="reset">重置</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>


<!-- 全局js -->
<script src="/Public/js/jquery.min.js?v=2.1.4"></script>
<script src="/Public/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="/Public/js/content.js?v=1.0.0"></script>
<script src="/Public/js/plugins/layer/layer.min.js"></script>

<script>
    //回复反馈
    function back_add() {

        //加载loading层
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });

        var  content=$("#content").val();
        var  title=$("#title").val();
        var url = "<{$SRVER_NAME}>/admin.php/Notice/addnotice";
        var tourl="<{$SRVER_NAME}>/admin.php/Notice/noticelist?rid=6";

        if (title == "" || content == "") {
            layer.close(index);
            layer.alert("发布不能为空！\r\n", {
                title: '提示框',
                icon: 0,
            });
            return false;
        }

        $.post(url, {content: content ,title: title}, function (data) {

            if (data.code =="1001") {

                var test=layer.alert(data.result,{title:'提示框',icon:1},function (index) {
                        window.location.href=tourl;
                    }
                );
            }
            else {
                layer.alert(data.result,{title:'提示框',icon:0});
            }
        });
        layer.close(index);
    }

    //文本自适应高度
    $.fn.autoHeight = function () {
        function autoHeight(elem) {
            elem.style.height = 'auto';
            elem.scrollTop = 0; //防抖动
            elem.style.height = elem.scrollHeight + 'px';
        }

        this.each(function () {
            autoHeight(this);
            $(this).on('keyup', function () {
                autoHeight(this);
            });
        });
    }
    $('textarea[autoHeight]').autoHeight();
</script>
</body>
</html>
